classdef LoadSet < handle
    properties
        NodeLoads    % struct array: nodeID, dof, value
        SurfaceLoads % struct array: entityID, setID, type, params
        BodyLoads    % struct array: entityID, setID, type, params
    end

    methods
        function obj = LoadSet()
            % 初始化空结构（定义字段，防止结构字段不一致）
            obj.NodeLoads = struct('nodeID', {}, 'dof', {}, 'value', {});
            obj.SurfaceLoads = struct('entityID', {}, 'setID', {}, 'type', {}, 'params', {});
            obj.BodyLoads = struct('entityID', {}, 'setID', {}, 'type', {}, 'params', {});
        end

        function addNodeLoad(obj, nodeID, dof, value)
            % 添加节点荷载项
            newEntry = struct('nodeID', nodeID, 'dof', dof, 'value', value);

            if numel(obj.NodeLoads) == 0
                obj.NodeLoads = newEntry;
            else
                obj.NodeLoads(end+1) = newEntry;
            end
        end

        function addSurfaceLoad(obj, entityID, setID, type, params)
            newEntry = struct('entityID', entityID, 'setID', setID, ...
                              'type', type, 'params', params);
            if numel(obj.SurfaceLoads) == 0
                obj.SurfaceLoads = newEntry;
            else
                obj.SurfaceLoads(end+1) = newEntry;
            end
        end

        function addBodyLoad(obj, entityID, setID, type, params)
            newEntry = struct('entityID', entityID, 'setID', setID, ...
                              'type', type, 'params', params);
            if numel(obj.BodyLoads) == 0
                obj.BodyLoads = newEntry;
            else
                obj.BodyLoads(end+1) = newEntry;
            end
        end
    end
end
